using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using Common;
using Common.Enum;

namespace ProjectView.ProjectControls
{
	public partial class UCADOption : UserControl
	{
		public static readonly DependencyProperty IsReadOnlyProperty = 
			DependencyProperty.Register("IsReadOnly", typeof(bool), typeof(UCADOption), new PropertyMetadata(false));

		public bool IsReadOnly
		{
			get
			{
				return (bool)GetValue(IsReadOnlyProperty);
			}
			set
			{
				SetValue(IsReadOnlyProperty, value);
			}
		}

		public List<KeyValuePair> AllTypeMethod
		{
			get
			{
				return EnumManagement.GetAllADTypeMethod();
			}
		}

		public UCADOption()
		{
			InitializeComponent();
		}

		private void Root_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
		{
			if (base.DataContext != null)
			{
				grid.ItemsSource = new List<object> { base.DataContext };
			}
		}

		public void UnSelectAll()
		{
			grid.UnselectAllCells();
		}

		private void grid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
		{
			if (IsReadOnly)
			{
				e.Cancel = true;
			}
		}

		public bool Validate()
		{
			return true;
		}
	}
}
